clear all;close all;
nntwarn off;
Test_error=3
while (Test_error>1)

 nDim = 5;
 nClass = 2;
 nHidden = 3;
 
 a= load('ofs_top_5_tr_n_t.txt');

 IP = a(:,1:nDim);
 OP = a(:,nDim+1:nDim+nClass);

    
IP=IP';
OP=OP';

[W1,b1,W2,b2]=initff(IP,nHidden,'logsig',nClass,'logsig');

disp_freq=1;
max_epoch=2000;
err_goal=0.0001;
min_grad=0.00001;
mu=.9;
mu_inc=.01;
mu_dec=.01;
tp=[disp_freq max_epoch err_goal min_grad];

[W1,b1,W2,b2,te,tr]=trainlm(W1,b1,'logsig',W2,b2,'logsig',IP,OP,tp);

save W1class1.50dat W1 -ASCII;
save W2class1.50dat W2 -ASCII;

save b1class1.50dat b1 -ASCII;
save b2class1.50dat b2 -ASCII;


TEST1 = load('ofs_top_5_te_n_t.txt');
TEST2 = TEST1(:,1:nDim);
TEST = TEST2';
OP1 = TEST1(:,nDim+1:nDim+nClass);
[a1,a2]= simuff(TEST,W1,b1,'logsig',W2,b2,'logsig');
a3=a2';
save test_i_o_50_net.txt a3 -ASCII
save test_i_o_50_out.txt OP1 -ASCII
[y1,I1]=max(a2);
[y2,I2]=max(OP1');
Test_error=0;
for i=1:34
    if(I1(i)~=I2(i))
        Test_error=Test_error+1;
    end
end
Test_error
[a4,a5]= simuff(IP,W1,b1,'logsig',W2,b2,'logsig');
a6=a5';
a7=OP';
[y3,I3]=max(a5);
[y2,I4]=max(OP);
Training_error=0;
for i=1:38
    if(I3(i)~=I4(i))
        Training_error=Training_error+1;
    end
end
Training_error
save i_o_50_net.txt a6 -ASCII
save i_o_50_out.txt a7 -ASCII

end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
